//
//  HNSH_XJDRTopView.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/5/30.
//

#import "HNSH_XJDRTopView.h"

@interface HNSH_XJDRTopView ()

/* topBgImgV */
@property (nonatomic, strong) UIImageView *topBgImgV;

/* infoBgImgV */
@property (nonatomic, strong) UIImageView *infoBgImgV;
/* infoTitleImgV */
@property (nonatomic, strong) UIImageView *infoTitleImgV;
/* infoLevelImgV */
@property (nonatomic, strong) UIImageView *infoLevelImgV;
/* moneyTitleLabel */
@property (nonatomic, strong) UILabel *moneyTitleLabel;
/* moneyLabel */
@property (nonatomic, strong) UILabel *moneyLabel;
/* levelLabel */
@property (nonatomic, strong) UILabel *levelLabel;

/* cellTtitleLabel */
@property (nonatomic, strong) UILabel *cellTtitleLabel;

@end

@implementation HNSH_XJDRTopView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
    }
    return self;
}

- (void)setModel:(HNSH_XJDRModel *)model {
    _model = model;
    self.topBgImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"xjdr_bottom_bg_%ld",model.level]];
    self.infoBgImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"xjdr_top_bg_%ld",model.level]];
    self.infoTitleImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"xjdr_top_title_%ld",model.level]];
    self.infoLevelImgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"xjdr_top_icon_%ld",model.level]];
    
    if (model.level == 1) {
        self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#3E4B77"];
        self.levelLabel.text = @"一星达人";
    } else if (model.level == 2) {
        self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#1C4390"];
        self.levelLabel.text = @"二星达人";
    } else if (model.level == 3) {
        self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#4C2189"];
        self.levelLabel.text = @"三星达人";
    } else if (model.level == 4) {
        self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#E37713"];
        self.levelLabel.text = @"四星达人";
    } else {
        self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#4D8F66"];
        self.levelLabel.text = @"普通用户";
    }
    
    self.moneyLabel.text = [NSString stringWithFormat:@"%@%@",model.amount,model.amount_desc];;
    
    self.cellTtitleLabel.text = [NSString stringWithFormat:@"%@%@",model.title,model.subtitle];
    self.cellTtitleLabel.attributedText = [ST_AttributeLabelTool handleLabelWithContent:self.cellTtitleLabel.text SelectContent:model.title CommonFont:self.cellTtitleLabel.font SpeFont:[UIFont boldSystemFontOfSize:16] Color:self.cellTtitleLabel.textColor];
}

- (void)configUI {
    UIImageView *topBgImgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 148+kNavBarAndStatusBarHeight)];
    topBgImgV.image = [UIImage imageNamed:@"xjdr_bottom_bg_0"];
    [self addSubview:topBgImgV];
    self.topBgImgV = topBgImgV;
    
    [self configInfoView];
    
}

- (void)configInfoView {
    self.infoBgImgV = [[UIImageView alloc]initWithFrame:CGRectMake(16, 12+kNavBarAndStatusBarHeight, kScreenWidth-32, 120)];
    self.infoBgImgV.image = [UIImage imageNamed:@"xjdr_top_bg_0"];
    [self addSubview:self.infoBgImgV];
    
    self.infoTitleImgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 68, 24)];
    self.infoTitleImgV.image = [UIImage imageNamed:@"xjdr_top_title_0"];
    [self.infoBgImgV addSubview:self.infoTitleImgV];
    
    self.infoLevelImgV = [[UIImageView alloc]initWithFrame:CGRectMake(self.infoBgImgV.width-24-68, 12, 68, 68)];
    self.infoLevelImgV.image = [UIImage imageNamed:@"xjdr_top_icon_0"];
    [self.infoBgImgV addSubview:self.infoLevelImgV];
    
    self.moneyTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(24, 41, 200, 17)];
    self.moneyTitleLabel.text = @"今日分红";
    self.moneyTitleLabel.textColor = [UIColor appWhiteLabelColor];
    self.moneyTitleLabel.font = [UIFont systemFontOfSize:12];
    [self.infoBgImgV addSubview:self.moneyTitleLabel];
    
    self.moneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(24, 62, 200, 28)];
    self.moneyLabel.text = @"134.00绿色能量";
    self.moneyLabel.textColor = [UIColor appWhiteLabelColor];
    self.moneyLabel.font = [UIFont boldSystemFontOfSize:20];
    [self.infoBgImgV addSubview:self.moneyLabel];
    
    self.levelLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.infoBgImgV.width-28-60, 88, 60, 20)];
    self.levelLabel.text = @"普通用户";
    self.levelLabel.textColor = [UIColor appWhiteLabelColor];
    self.levelLabel.font = [UIFont systemFontOfSize:11];
    self.levelLabel.textAlignment = NSTextAlignmentCenter;
    self.levelLabel.backgroundColor = [UIColor colorWithHexString:@"#E37713"];
    self.levelLabel.layer.cornerRadius = 10;
    self.levelLabel.layer.masksToBounds = YES;
    [self.infoBgImgV addSubview:self.levelLabel];
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
